#!/bin/bash

# sh build.sh
# sh build.sh debug
# sh build.sh [debug|release] test

KPERF_PATH=../../install/libkperf
LIB_KPERF_LIBPATH=$KPERF_PATH/lib
LIB_KPERF_INCPATH=$KPERF_PATH/include
options="-DLIB_KPERF_LIBPATH=$LIB_KPERF_LIBPATH -DLIB_KPERF_INCPATH=$LIB_KPERF_INCPATH"

if [ "$1" = "debug" ];then
    options="${options} -DWITH_DEBUG=ON"
elif [ "$1" = "test" ];then
    echo "Invalid argument, please check build.sh."
    exit -1
fi

rm -rf build
mkdir build && cd build
cmake ../ ${options}
make -j`nproc`
cd -

if [ "$2" = "test" ];then
    sh ./test.sh
fi